package com.ys.data.controller;


import com.common.pojo.Result;
import com.common.util.DingDingUtils;
import com.common.vo.dd.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "钉钉发送消息相关API")
@RestController
@RequestMapping("ding")
public class DingDingController {

    @PostMapping("text")
    @ApiOperation(value = "测试发送文本钉钉消息",notes = "测试")
    public Result<?> text(@RequestBody DingDingTextVo dingDingTextVo) throws Exception {
        DingDingUtils.sendToDingDing(dingDingTextVo.getJSONObjectString(),dingDingTextVo.getMsgType());
        return null;
    }

    @PostMapping("link")
    @ApiOperation(value = "测试发送link钉钉消息",notes = "测试")
    public Result<?> link(@RequestBody DingDingLinkVo dingDingLinkVo) throws Exception {
        DingDingUtils.sendToDingDing(dingDingLinkVo.getJSONObjectString(),dingDingLinkVo.getMsgType());
        return null;
    }

    @PostMapping("mark")
    @ApiOperation(value = "测试发送mark钉钉消息",notes = "测试")
    public Result<?> mark(@RequestBody DingDingMarkDownVo dingDingMarkDownVo) throws Exception {
        DingDingUtils.sendToDingDing(dingDingMarkDownVo.getJSONObjectString(),dingDingMarkDownVo.getMsgType());
        return null;
    }

    @PostMapping("action")
    @ApiOperation(value = "测试发送图片加长文钉钉消息",notes = "测试")
    public Result<?> action(@RequestBody DingDingActionCardVo dingDingActionCardVo) throws Exception {
        DingDingUtils.sendToDingDing(dingDingActionCardVo.getJSONObjectString(),dingDingActionCardVo.getMsgType());
        return null;
    }

    @PostMapping("feedCard")
    @ApiOperation(value = "测试资讯卡钉钉消息",notes = "测试")
    public Result<?> feedCard(@RequestBody DingDingFeedCardVo dingDingFeedCardVo) throws Exception {
        DingDingUtils.sendToDingDing(dingDingFeedCardVo.getJSONObjectString(),dingDingFeedCardVo.getMsgType());
        return null;
    }
}
